<?php
/**
 * (C)2012-2014 twcms.com TongWang Inc.
 * Author: wuzhaohuan <kongphp@gmail.com>
 */

defined('TWCMS_PATH') or exit;

class user_group extends model {
	function __construct() {
		$this->table = 'user_group';	// 表名
		$this->pri = array('groupid');	// 主键
		$this->maxid = 'groupid';		// 自增字段
	}

    public function get_html_by_gid($gid, $tips = '选择群组') {
        $group_arr = $this->find_fetch();

        $s = '<select name="gid" id="gid">';
        if(empty($group_arr)) {
            $s .= '<option value="0">没有分类</option>';
        }else{
            $s .= '<option value="0">'.$tips.'</option>';
            foreach($group_arr as $v) {
                $s .= '<option value="'.$v['groupid'].'"'.($v['groupid'] == $gid ? ' selected="selected"' : '').'>' . $v['groupname'] . '</option>';
            }
        }
        $s .= '</select>';
        return $s;
    }
}
